package Thread;

public class SycDemo3 {
    public static void main(String[] args) {
        F f = new F();
        Thread t = new Thread(){
            @Override
            public void run() {
                F.B();
            }
        };

        Thread t1 = new Thread(){
            @Override
            public void run() {
                F.B();
            }
        };

        t.start();
        t1.start();
    }
}
 class F{
    //public static synchronized void B
    public static void B(){
        synchronized(F.class){
        try {
            System.out.println("执行");
            Thread.sleep(1000);
            System.out.println("完毕");
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
    }
 }